--
-- DailyRarePanel
-- yu.yu
-- 2019.1.4
--

local NewDailyRareRender = import(".renders.NewDailyRareRender")

local ClassRef = app.mvc.createPanelClass(...)

function ClassRef.create(node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.DailyNewRarePanel))
	if node == nil then
		ccui.Helper:doLayout(sprite)
	end
	sprite:init()
	return sprite
end

function ClassRef:init(data)
    self.super.init(self, data)

    self._boxNode = {}
    for i = 1, 3 do
        local render = NewDailyRareRender.create(self._ui["node_"..i])
        render:onBtnClick(function(op, data) executeFunc(self._onOperate, op, data) end)
        render:setData(i) 
        self._boxNode[i] = render
    end
    self:refresh()
end

function ClassRef:refresh()
    -- 宝箱的次数和数量刷新
    for i = 1, 3 do
        self._boxNode[i]:refreshBoxNum(i)
    end
end

function ClassRef:onOperate(cb)
    self._onOperate = cb
end

return ClassRef